package com.gin.supermarket_inventory_system.inventory.dto.form;

import com.gin.supermarket_inventory_system.inventory.entity.InventoryPo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;
import org.springframework.beans.BeanUtils;

/**
 * 添加库存
 * @since : 2023/10/10 12:27
 * @author : ginstone
 * @version : v1.0.0
 **/
@Getter
@Setter
@Schema(description = "表单对象:添加库存")
public class InventoryAddForm {
    @Schema(description = "名称")
    @NotEmpty
    String name;

    @Schema(description = "规格")
    @NotEmpty
    String spec;

    @Schema(description = "条码")
    @NotEmpty
    String barcode;

    @Schema(description = "商品信息ID")
    @NotNull
    long commodityId;

    @Schema(description = "零售价")
    @Min(0L)
    @NotNull
    double price;

    public InventoryPo toPo() {
        final InventoryPo po = new InventoryPo();
        BeanUtils.copyProperties(this, po);
        po.setAmount(0);
        return po;
    }
}